
package com.ksvip.next.components.sequence.single.core;

import java.util.concurrent.atomic.AtomicLong;

public class SingleSequenceRange {
    private final long       min;
    private final long       max;
    private final AtomicLong value;

    public boolean isOver() {
        return this.value.get() > this.max;
    }

    public SingleSequenceRange(long min, long max) {
        this.min = min;
        this.max = max;
        this.value = new AtomicLong(min);
    }

    public long getAndIncrement() {
        long currentValue = this.value.getAndIncrement();
        return currentValue > this.max ? -1L : currentValue;
    }

    public long getMin() {
        return this.min;
    }

    public long getMax() {
        return this.max;
    }
}
